package Practice;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;

public class Demo1 {
    public static void main(String[] args) {
TheQQ theQQ = InputUtil.getInputObject(new TheQQ(),"欢迎注册","注册");
        try (Connection connection = DB_Util.GetConnection();){

//            String sql1="CREATE TABLE the_qq(name INT PRIMARY KEY AUTO_INCREMENT,QQ_id VARCHAR(32),QQ_password VARCHAR(32),nickname VARCHAR(32),email VARCHAR(32))";
//            String sql2="USE the_qq";
//            Statement statement = connection.createStatement();
//            statement.execute(sql1);
//            statement.execute(sql2);
            String sql = "INSERT INTO the_qq(name,QQ_id,QQ_password,nickname,email) VALUES(?,?,?,?,?)";
            PreparedStatement ps = connection.prepareStatement(sql);
            ps.setString(1,theQQ.getName());
            ps.setString(2,theQQ.getQQ_id());
            ps.setString(3,theQQ.getQQ_password());
            ps.setString(4,theQQ.getNickname());
            ps.setString(5,theQQ.getEmail());
            int num=ps.executeUpdate();
            if (num>0){
                System.out.println("注册成功");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }


    }
}
